#ifndef WIDGET_H
#define WIDGET_H

#include <QMatrix4x4>
#include <QOpenGLBuffer>
#include <QOpenGLFunctions>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLWidget>
#include "transform3d.h"

class QOpenGLShaderProgram;

class Widget : public QOpenGLWidget, protected QOpenGLFunctions
{
    Q_OBJECT

public:
    Widget(QWidget *parent = Q_NULLPTR);
    virtual ~Widget();

protected:
    void initializeGL();
    void resizeGL(int width, int height);
    void paintGL();

private:
    void teardownGL();
    void printContextInformation();

protected slots:
    void update();

private:
    // OpenGL State Information
    QOpenGLShaderProgram *program;
    QOpenGLVertexArrayObject vao;
    QOpenGLBuffer vbo;
    QOpenGLBuffer ebo;

    // Shader Information
    int u_modelToWorld;
    int u_worldToView;
    int u_viewToClip;
    QMatrix4x4 m_projection2; // projection matrix: view to clip
    QMatrix4x4 m_projection;  // view matrix: world to view(camera)
    Transform3D m_transform;  // model matrix: local to world
};

#endif // WIDGET_H
